home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / wmenu.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  68 lines

  1. ; $Id: wmenu.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple non-exclusive menu widget.
  7. ; The menu contains a list of colors.  When a button is
  8. ; pushed in (selected), the message, "Color selected." 
  9. ; is printed in the IDL window.  When a button that has
  10. ; been previously pushed in is de-selected, the message
  11. ; "Color de-selected." is printed in the IDL window.
  12.  
  13. ; Non-exclusive menus are lists of buttons in which any
  14. ; number of buttons can be selected at the same time.
  15.  
  16. ; For an example of an exclusive menu, see the routine
  17. ; WEXCLUS.PRO.
  18.  
  19.  
  20.  
  21.  
  22. PRO wmenu_event, event
  23. ; This procedure is the event handler for a non-exclusive menu widget.
  24.  
  25. ; Use WIDGET_CONTROL to get the VALUE of any action and put it into 'value':
  26.  
  27. WIDGET_CONTROL, event.id, GET_VALUE = value
  28.  
  29. ; When a widget event occurs, an event structure is returned.
  30. ; Part of that structure is a 'select' field that is equal to 
  31. ; 1 if a button was selected or 0 if the button was de-selected.
  32. ; For Menu items, any VALUE returned will be the text of the menu item.
  33. ; Therefore, we can just print out the words as they are selected.
  34.  
  35. IF (event.select EQ 1) THEN PRINT, value, ' selected.' $
  36.     ELSE PRINT, value, ' de-selected.'
  37.  
  38. END
  39.  
  40.  
  41.  
  42. PRO wmenu, GROUP = GROUP
  43. ; This procedure creates a non-exclusive menu widget.
  44.  
  45. ; Make the top-level base widget:
  46.  
  47. base = WIDGET_BASE(TITLE = 'Non-Exclusive Menu Example', /COLUMN, XSIZE = 300)
  48.  
  49. ; Make 'items' a 1-dimensional text array containing the menu items:
  50.  
  51. items = ['Red','Orange','Yellow','Green','Blue','Indigo','Violet']
  52.  
  53. ; The XMENU procedure will automatically create the menu items for us.
  54. ; We only have to give it the menu item labels (in the array 'items')
  55. ; and, optionally, the base to which the menu belongs (here we use 'base',
  56. ; the top-level base widget).  The /NONEXCLUSIVE keyword makes the 
  57. ; menu non-exclusive:
  58.  
  59. XMENU, items, base, /NONEXCLUSIVE    
  60.  
  61. ; Realize the widgets:
  62. WIDGET_CONTROL, base, /REALIZE
  63.  
  64. ; Hand off to the XMANAGER:
  65. XMANAGER, 'wmenu', base, GROUP_LEADER = GROUP
  66.  
  67. END
  68.